#!/usr/bin/env python3
"""
手写数字识别训练平台启动脚本
"""

import os
import sys
import subprocess

def check_dependencies():
    """检查并安装依赖"""
    try:
        import flask
        import sklearn
        import numpy
        import joblib
        print("✅ 所有依赖已安装")
        return True
    except ImportError as e:
        print(f"❌ 缺少依赖: {e}")
        print("正在安装依赖...")
        subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
        return True

def main():
    """主函数"""
    print("🚀 启动手写数字识别训练平台...")
    
    # 检查依赖
    check_dependencies()
    
    # 创建必要的目录
    os.makedirs('static/models', exist_ok=True)
    
    # 启动应用
    from app import app
    print("📱 应用启动成功！")
    print("🌐 请在浏览器中访问: http://localhost:5000")
    print("📖 使用说明请查看 README.md")
    
    app.run(debug=True, host='0.0.0.0', port=5000)

if __name__ == '__main__':
    main()
